from django.urls import path
from apps.users.views import UsernameCountView, RegisterView, MobileCountView, LoginView, LogoutView
from apps.users.views import CenterView,EmailView,EmailVerifyView,AddressCreateView
from apps.users.views import AddressView,AddressUpdateAndDeleteView,DefaultAddressView,UpdateTitleAddressView
from apps.users.views import UpdatePasswordView,UserHistoryView
# 注册转换器
from utils.converters import UsernameConverter, MobileConverter
from django.urls import register_converter
register_converter(UsernameConverter, 'username')
register_converter(MobileConverter, 'mobile')

urlpatterns = [
    path('usernames/<username:username>/count/', UsernameCountView.as_view()),
    path('mobile/<mobile:mobile>/count/', MobileCountView.as_view()),
    path('register/', RegisterView.as_view()),
    path('login/', LoginView.as_view()),
    path('logout/', LogoutView.as_view()),
    path('info/',CenterView.as_view()),
    path('emails/',EmailView.as_view()),
    path('emails/verification/',EmailVerifyView.as_view()),
    path('addresses/create/',AddressCreateView.as_view()),
    path('addresses/',AddressView.as_view()),
    path('addresses/<int:address_id>/',AddressUpdateAndDeleteView.as_view()),
    path('addresses/<int:address_id>/default/', DefaultAddressView.as_view()),
    path('addresses/<int:address_id>/title/', UpdateTitleAddressView.as_view()),
    path('password/', UpdatePasswordView.as_view()),
    path('browse_histories/', UserHistoryView.as_view()),
]


